package com.sgb.kjwl.view.ui.activity.enterprise;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import androidx.databinding.DataBindingUtil;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityTalentUserdetailBinding;
import com.sgb.kjwl.di.enterprise.DaggerEnterpriseComponent;
import com.sgb.kjwl.di.enterprise.EnterpriseModule;
import com.swgk.core.view.entity.TalentEntity;
import com.sgb.kjwl.viewmodel.enterprise.TalentDeilModel;
import com.swgk.core.base.di.AppComponent;

import java.io.Serializable;

import javax.inject.Inject;

public class TalentDetailActivity extends AppActivity {
    private ActivityTalentUserdetailBinding binding;
    @Inject
    TalentDeilModel makeOverDetailModel;

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerEnterpriseComponent.builder().appComponent(appComponent)
                .enterpriseModule(new EnterpriseModule(this))
                .build()
                .inject(this);
    }


    public static void start(Context mContext, TalentEntity entity){
        Intent mIntent = new Intent();
        mIntent.putExtra("data",(Serializable)entity);
        mIntent.setClass(mContext,TalentDetailActivity.class);
        mContext.startActivity(mIntent);

    }


    @Override
    protected void initView() {
        super.initView();
        binding = DataBindingUtil.setContentView(this, R.layout.activity_talent_userdetail);
        binding.ivBack.setOnClickListener(view->{
            finish();
        });
        TalentEntity entity = (TalentEntity)getIntent().getSerializableExtra("data");
        if(entity!=null) {
            binding.tvName.setText(TextUtils.isEmpty(entity.getName()) ? "/" : entity.getName());
            binding.tvYear.setText(entity.getExperience()<=0? "/" :entity.getExperience() + "年");
            binding.tvAge.setText(entity.getAge()<=0?"/":entity.getAge() + "岁");
            binding.tvContent1.setText(TextUtils.isEmpty(entity.getPosition())?"/":entity.getPosition());
            binding.tvContent2.setText(TextUtils.isEmpty(entity.getBusiness())?"/":entity.getBusiness());
            binding.tvContent3.setText(TextUtils.isEmpty(entity.getProfile())?"/":entity.getProfile());

            if(!TextUtils.isEmpty(entity.getHeadImg())){
                Glide.with(this).load(entity.getHeadImg() + "")
                        .apply(RequestOptions.bitmapTransform(new CircleCrop()).placeholder(R.mipmap.def_photo))
                        .into(binding.imageHeand);
            }else{
                Glide.with(this).load("")
                        .apply(RequestOptions.bitmapTransform(new CircleCrop()).placeholder(R.mipmap.def_photo))
                        .into(binding.imageHeand);
            }
        }


    }
}
